﻿@model HROReporting.Controllers.ViewModels.Docent.DocentIndexView

@{
    ViewBag.Title = "Index";
}

<h1 class="title">Zoek een docent</h1>

@using (Html.BeginForm())
{
    @Html.Hidden("HiddenTerm")
    <div id="docenten-container">
        <table class="search">
            <tr>
                <td class="search"><input id="search-bar" name="ZoekTerm" type="text" placeholder="Zoek a.d.h.v. docentcode, naam of locatie" /></td>
                <td class="search"><input type="submit" id="btnSubmit" value="Zoeken"  /></td>
            </tr>
        </table>
        @if (Model.Docenten != null && Model.Docenten.Count() > 0)
        {
            foreach (var docent in Model.Docenten)
            {
                <h1 class="title-zoekterm">Resultaten voor: @Model.ZoekTerm</h1>
                <table class="list">
                    <tr>
                        <th><h1 class="title">Docentcode:</h1></th>
                        <th><h1 class="title">Achternaam:</h1></th>
                        <th><h1 class="title">Email:</h1></th>
                    </tr>
                    <tr>
                        <td>
                            @docent.DocentCode.Code
                        </td>
                        <td>
                            @docent.Achternaam
                        </td>
                        <td>
                            @docent.Email
                        </td>
                        <td>
                            <a href="/Docent/Details/@docent.DocentCode.Code">Bekijk</a>
                        </td>
                    </tr>
                </table>
            }
        }
        else if (Model.ZoekTerm != null)
        {
            <p>Geen resultaten voor "@Model.ZoekTerm".</p>
        }
    </div>
    
    <script type="text/javascript">

        $("#search-bar").autocomplete({
            source: '@Url.Action("List")'
        });

        $('#search-bar').keypress(function (e) {
            if (e.which == 13) {
                $('form').submit();
            }
        });
  
    </script>  
}

